#include "WoodenBall.h"
#include "Line.h"

CWoodenBall::CWoodenBall()
	{
	SetRad( 12 );
	SetPos( TRealPoint(100,500) );
	SetAcc( TRealVector(0.0f, -0.01f) );
	SetVel( TRealVector() );
	}

CWoodenBall* CWoodenBall::NewL()
	{
	return new (ELeave)CWoodenBall;
	}

TBool CWoodenBall::Hit( CLine* aLine )
	{
	if( !aLine->Hit( this ) )
		{
		return EFalse;
		}
	SetVel( GetVel() - GetAcc() );
	TRealVector mirror = GetVel().Mirror( aLine->GetDir() );
	mirror *= 1.0f;
	SetVel( mirror );
	if( !aLine->IsVertical() )
		{
		aLine->SetStart(TPoint(-1,-1));
		aLine->SetEnd(TPoint(0,0));
		}
	return ETrue;
	}
